package com.aigou.admin.aigouspringboot.service.impl;

import com.aigou.admin.aigouspringboot.common.Constants;
import com.aigou.admin.aigouspringboot.entity.SearchHistory;
import com.aigou.admin.aigouspringboot.mapper.SearchHistoryMapper;
import com.aigou.admin.aigouspringboot.service.SearchHistoryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SearchHistoryServiceImpl implements SearchHistoryService {
    @Resource
    private SearchHistoryMapper searchHistoryMapper;
    @Override
    public List<SearchHistory> searchHistory() {
        return searchHistoryMapper.selectAll();
    }

    @Override
    public PageInfo<SearchHistory> selectSearchHistory(Integer current) {
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        List<SearchHistory> list = searchHistoryMapper.selectAll();
        return new PageInfo<>(list);
    }

    @Override
    public SearchHistory selectById(String id) {
        return searchHistoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public int save(SearchHistory searchHistory) {
        return searchHistoryMapper.insert(searchHistory);
    }

    @Override
    public int edit(SearchHistory searchHistory) {
        return searchHistoryMapper.updateByPrimaryKey(searchHistory);
    }

    @Override
    public int deleteById(String id) {
        return searchHistoryMapper.deleteByPrimaryKey(id);
    }
}
